package com.baizhi.controller;


import com.baizhi.entity.Category;
import com.baizhi.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 分类 前端控制器
 * </p>
 *
 * @author 2107class
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/categories")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public List<Category> query(){
        List<Category> query = categoryService.query();
        return query;
    }

    @GetMapping("{id}")
    public Category queryOne(@PathVariable("id") Integer id){
        Category category = categoryService.queryOne(id);
        return category;
    }

}

